/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/

#ifdef __cplusplus
extern "C" {
#endif


#ifndef __FLGR_DATA_TOOLS_PSTACK_H 
#define __FLGR_DATA_TOOLS_PSTACK_H 

#include <flgrCoreDll.h>
#include <flgrCoreTypes.h>
#include <flgrCoreErrors.h>
#include <flgrCoreVector.h>

/*!
 * \addtogroup group_fulguro_datatools_pstack
 * @{
 */  



  typedef struct FLGR_McStackLink FLGR_McStackLink; 

  struct FLGR_McStackLink { 
    FLGR_McStackLink *lower; 
    int row;
    int col;
  }; 
  


  typedef struct FLGR_McStack FLGR_McStack;

  //typedef int (*FctStackCompare_t) (FLGR_McStack *stack, FLGR_Vector *priorityLabel); 
  //typedef int (*FLGR_VectorCompare) (FLGR_Vector *vec1, FLGR_Vector *vec2); 

  /*!
   * Stack Access Structure
   */    
  struct FLGR_McStack {
    FLGR_Vector *priorityLabel;      //!< Stack priority label
    FLGR_Type type;                  //!< Type of the priority label
    int size;                        //!< Number of element
    FLGR_McStackLink *top;             //!< pointer to the top of the stack
    FLGR_McStack *next;                //!< Pointer to a lower priority stack
    FLGR_McStack *previous;            //!< Pointer to a higher priority stack
    FLGR_VectorCompare compareStackFunction; //!< Function used to compare Stack Priority label
  };


  /*!
   * Priority Stack Structure
   */    
  typedef struct {
    int nbPriority;                         //!< Number of stack
    FLGR_McStack *first;                      //!< pointer to first Stack structure
    FLGR_McStack *last;                       //!< pointer to last Stack structure
    FLGR_Type type;                         //!< Type used in functions using priority stack
    FLGR_VectorCompare compareStackFunction; //!< Function used to compare Stack Priority label
 }FLGR_PStack;


  EXPORT_LIB FLGR_PStack *flgr_pstack_create(FLGR_Type type, FLGR_VectorCompare fcompare);
  EXPORT_LIB void flgr_pstack_destroy(FLGR_PStack *pstack);

  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_first_no_empty_stack(FLGR_PStack *pstack);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_last_no_empty_stack(FLGR_PStack *pstack);

  EXPORT_LIB int flgr_pstack_check_stack_priority(FLGR_McStack *stack, FLGR_Vector *priorityLabel);

  EXPORT_LIB FLGR_Ret flgr_pstack_push(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);
  EXPORT_LIB FLGR_Ret flgr_pstack_pop_stack(FLGR_McStack *stk, int *row, int *col);
  EXPORT_LIB FLGR_Ret flgr_pstack_push_stack(FLGR_McStack *stk, int row, int col);

  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);

  EXPORT_LIB FLGR_Vector *flgr_pstack_get_label_stack(FLGR_McStack *stack);
  EXPORT_LIB int flgr_pstack_is_last_stack(FLGR_McStack *stack);

  EXPORT_LIB FLGR_Ret flgr_pstack_set_stack_priority(FLGR_McStack *stack, FLGR_Vector *priorityLabel);

  EXPORT_LIB void flgr_pstack_set_stack_priority_fgBIT(FLGR_McStack *stack, FLGR_Vector *priorityLabel);
  EXPORT_LIB void flgr_pstack_set_stack_priority_fgUINT8(FLGR_McStack *stack, FLGR_Vector *priorityLabel);
  EXPORT_LIB void flgr_pstack_set_stack_priority_fgUINT16(FLGR_McStack *stack, FLGR_Vector *priorityLabel);
  EXPORT_LIB void flgr_pstack_set_stack_priority_fgUINT32(FLGR_McStack *stack, FLGR_Vector *priorityLabel);
  EXPORT_LIB void flgr_pstack_set_stack_priority_fgINT8(FLGR_McStack *stack, FLGR_Vector *priorityLabel);
  EXPORT_LIB void flgr_pstack_set_stack_priority_fgINT16(FLGR_McStack *stack, FLGR_Vector *priorityLabel);
  EXPORT_LIB void flgr_pstack_set_stack_priority_fgINT32(FLGR_McStack *stack, FLGR_Vector *priorityLabel);
  EXPORT_LIB void flgr_pstack_set_stack_priority_fgFLOAT32(FLGR_McStack *stack, FLGR_Vector *priorityLabel);
  EXPORT_LIB void flgr_pstack_set_stack_priority_fgFLOAT64(FLGR_McStack *stack, FLGR_Vector *priorityLabel);

  EXPORT_LIB FLGR_Ret flgr_pstack_push_fgBIT(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);
  EXPORT_LIB FLGR_Ret flgr_pstack_push_fgUINT8(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);
  EXPORT_LIB FLGR_Ret flgr_pstack_push_fgUINT16(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);
  EXPORT_LIB FLGR_Ret flgr_pstack_push_fgUINT32(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);
  EXPORT_LIB FLGR_Ret flgr_pstack_push_fgINT8(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);
  EXPORT_LIB FLGR_Ret flgr_pstack_push_fgINT16(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);
  EXPORT_LIB FLGR_Ret flgr_pstack_push_fgINT32(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);
  EXPORT_LIB FLGR_Ret flgr_pstack_push_fgFLOAT32(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);
  EXPORT_LIB FLGR_Ret flgr_pstack_push_fgFLOAT64(FLGR_PStack *pstack, FLGR_Vector *priorityLabel, int row, int col);

  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack_fgBIT(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack_fgUINT8(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack_fgUINT16(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack_fgUINT32(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack_fgINT8(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack_fgINT16(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack_fgINT32(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack_fgFLOAT32(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_create_stack_fgFLOAT64(FLGR_PStack *pstack,FLGR_Vector *priorityLabel);

  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack_fgBIT(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack_fgUINT8(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack_fgUINT16(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack_fgUINT32(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack_fgINT8(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack_fgINT16(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack_fgINT32(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack_fgFLOAT32(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);
  EXPORT_LIB FLGR_McStack *flgr_pstack_get_stack_fgFLOAT64(FLGR_PStack *pstack, FLGR_Vector *priorityLabel);

  //!@}

#endif 

#ifdef __cplusplus
}
#endif
